package org.jeecg.modules.mobile.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.mobile.entity.MobileUserConfig;
import org.jeecg.modules.mobile.entity.vo.MobileUserConfigAddVO;
import org.jeecg.modules.mobile.mapper.MobileUserConfigMapper;
import org.jeecg.modules.mobile.service.IMobileUserConfigService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 移动端用户配置信息
 * @Author: jeecg-boot
 * @Date:   2023-09-14
 * @Version: V1.0
 */
@Service
public class MobileUserConfigServiceImpl extends ServiceImpl<MobileUserConfigMapper, MobileUserConfig> implements IMobileUserConfigService {

    /**
     * 保存
     * @param vo
     */
    @Override
    public void saveConfig(MobileUserConfigAddVO vo) {
        MobileUserConfig one = this.getOne(new LambdaQueryWrapper<MobileUserConfig>()
                .eq(MobileUserConfig::getUserId, vo.getUserId())
                .last("limit 1"));
        if (one == null) {
            one = new MobileUserConfig();
        }
        one.setUserId(vo.getUserId());
        one.setDeptId(vo.getDeptId());
        one.setWarehouseId(vo.getWarehouseId());
        this.saveOrUpdate(one);
    }
}
